<template>
  <div class="container">
    <div class="box">
      <div class="left">
        <img src="../assets/left.png" alt="" />
      </div>
      <div class="right">
        <h4>超市后台管理系统</h4>
        <form action="">
          <input
            class="acc"
            type="text"
            placeholder="用户名"
            v-model="YzhvipName"
          />

          <input
            class="acc"
            :type="a"
            placeholder="密码"
            v-model="YzhvipPassword"
          />
          <i :class="className" @click="btnOpen"></i>
          <input
            class="submit"
            type="submit"
            value="Login"
            @click.prevent="handleLogin()"
          />
        </form>
        <div class="fn">
          <a href="javascript:;" @click.prevent="handleregister">注册账号</a>
          <a href="javascript:;">找回密码</a>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { SaleLogin } from "../api/login";
export default {
  components: {},
  data() {
    return {
      a: "password",
      className: "iconfont icon-visible",
      flag: true,
      YzhvipName: "",
      YzhvipPassword: "",
      st: "false", //false为不保存登录
    };
  },
  methods: {
    handleLogin() {
      if (this.YzhvipName === "") {
        this.$message.error("用户名不能为空");
        return;
      }
      if (this.YzhvipPassword === "") {
        this.$message.error("密码不能为空");
        return;
      }
      let logindata = {
        YzhvipName: this.YzhvipName,
        YzhvipPassword: this.YzhvipPassword,
      };
      SaleLogin(logindata).then((rsp) => {
        console.log(rsp);
        if (rsp.code === 0) {
          this.dialogFormVisible = false;
          this.$message.success("登录成功,超市系统欢迎您!");
          this.$router.replace({ path: '/Index' });
        } else {
          this.$message.error(rsp.msg, rsp.code);
        }
      });
    },
    handleregister() {
      this.$router.replace({ path: "/Register" });
    },
    btnOpen() {
      if (this.flag) {
        (this.a = "text"), (this.flag = !this.flag);
        this.className = "iconfont icon-icon-eye-open";
      } else {
        this.a = "password";
        this.flag = !this.flag;
        this.className = "iconfont icon-visible";
      }
    },
  },
};
</script>




<style scoped>
/* .loginForm {
  -webkit-border-radius: 5px;
  border-radius: 5px;
  -moz-border-radius: 5px;
  background-clip: padding-box;
  margin: 180px auto;
  width: 350px;
  padding: 35px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;
}
a {
  text-decoration: none;
  color: #333;
  text-decoration: underline;
} */

@font-face {
  font-family: "iconfont";
  src: url("../assets/font/iconfont.woff2?t=1638953664256") format("woff2"),
    url("../assets/font/iconfont.woff?t=1638953664256") format("woff"),
    url("../assets/font/iconfont.ttf?t=1638953664256") format("truetype");
}

.box .iconfont {
  display: absolute;
  font-size: 30px;
  bottom: 0;
  margin-top: 80px;
  margin-left: -30px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 10px;
}
.container {
  background-color: rgb(255, 255, 255);
  height: 100%;
  position: fixed;
  width: 100%;
}
.container::before {
  content: "";
  width: 100%;
  height: 100%;
  position: fixed;
  z-index: -1;
  background: linear-gradient(120deg, #e0c3fc 0%, #8ec5fc 100%) no-repeat;
}

::selection {
  color: #fff;
  background-color: rgb(144, 129, 241);
}

.box {
  display: flex;
  overflow: hidden;
  width: 1000px;
  height: 600px;
  background-color: rgba(255, 255, 255, 60%);
  border-radius: 1.5rem;
  margin: 50px auto;
  box-shadow: 0 0 1rem 0.2rem rgb(0 0 0 / 10%);
}

.box .left {
  position: relative;
  width: 35%;
  height: 100%;
  background-color: skyblue;
}

.box .left img {
  position: absolute;
  width: 100%;
  height: 100%;
  /* background-image: url(../assets/img/left.png); */
  background-size: cover;
}

.box .right {
  display: flex;
  width: 65%;
  flex-direction: column;
  align-items: center;
}

.box .right h4 {
  color: rgb(144, 129, 241);
  font-size: 30px;
  margin-top: 5rem;
}

.box .right form {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.box .right form .acc {
  outline: none;
  width: 80%;
  height: 30px;
  font-size: 1rem;
  margin-top: 5rem;
  padding: 0.1rem 0 0 1.6rem;
  border: none;
  border-bottom: 1px solid rgb(144, 129, 241);
  color: rgb(144, 129, 241);
  background-color: rgba(0, 0, 0, 0);
}

.right form .acc:focus {
  outline: none;
  color: rgb(144, 129, 241);
  padding: 0.1rem 0 0 1.6rem;
}

.right .submit {
  width: 60%;
  height: 3rem;
  color: #f6f6f6;
  background-image: linear-gradient(120deg, #e0c3fc 0%, #8ec5fc 100%);
  font-size: 1rem;
  border: none;
  border-radius: 0.5rem;
  margin: 3rem 0 0 50%;
  transform: translateX(-50%);
}

.right .submit:hover {
  box-shadow: 0 0 2rem -0.5rem rgb(0 0 0 / 15%);
}

.right .fn {
  display: flex;
  justify-content: space-between;
  margin-top: -20px;
  width: 70%;
}

.right .fn a {
  font-size: 0.8rem;
  margin-top: 5rem;
  padding: 1rem 2rem;
  color: #666;
}

.right .fn a:hover {
  color: rgb(144, 129, 241);
}
</style>
